package com.example.demo.mapper;

import com.example.demo.entity.Bill;
import com.example.demo.entity.Bill1;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BillMapper {
    @Insert("insert into bill(BillId,CustomerId,BookName,BookId,Price,OrderNumber,Money,Date,Address,PhoneNumber,DeliveryId) values(uuid_short(),#{CustomerId},#{BookName},#{BookId},#{Price},#{OrderNumber},#{Money},#{Date},#{Address},#{PhoneNumber},#{DeliveryId})")
    void insertBill(Bill bill);

    @Select("select BillId,CustomerId,BookName,BookId,Price,OrderNumber,Money,Date,Address,PhoneNumber,DeliveryName from bill join delivery on bill.deliveryId=delivery.deliveryId where CustomerId=#{id} order by Date desc")
    List<Bill1> selectBill(String id);

    @Delete("delete from bill where BillId=#{id}")
    void deleteBill(String id);

    @Select("select BillId,CustomerId,BookName,BookId,Price,OrderNumber,Money,Date,Address,PhoneNumber,DeliveryName from bill join delivery on bill.deliveryId=delivery.deliveryId where CustomerId=#{id} and Date=#{date} order by Date desc")
    List<Bill1> selectBiBD(String id, String date);
}
